﻿using AutoMapper;
using D.IdentityDbStore.Entities;

namespace D.IdentityDbStore.Mappers
{
    public class IdentityResourceMapperProfile : Profile
    {
        public IdentityResourceMapperProfile()
        {

  			CreateMap<IdentityResourceProperty, KeyValuePair<string, string>>()
                .ReverseMap();
            CreateMap<IdentityResource, IdentityServer4.Models.IdentityResource>(MemberList.Destination)
                  .ConstructUsing(src => new IdentityServer4.Models.IdentityResource())
                  .ReverseMap();

            CreateMap<IdentityResourceClaim, string>()
               .ConstructUsing(x => x.Type)
               .ReverseMap()
               .ForMember(dest => dest.Type, opt => opt.MapFrom(src => src));
        }
    }
}
